def DisplayChars():
	####################################
	# Just ignore this section for now #
	####################################

	import os, GameLogic as gl, VideoTexture as vt
	#from PIL import Image
	scene = gl.getCurrentScene()
	
	adder = scene.objects['OBAdder']
	#scene.addObject('CharIcon', adder)
	
	x = 0
	y = 0
	icon = 1
	first = 1
	
	files = os.listdir(gl.expandPath('//Karts'))
	
	# List of images we'll combine
	images = []

	final = Image.new('RGB', (640, 640))
	
	for file in files:
		# Check to see if we have a folder that's not the .svn folder
		if not file == ".svn" and os.path.isdir(gl.expandPath('//Karts/'+file)):
			
			# Add the object
			name = 'CharIcon.%03d' % icon
			obj = scene.addObject(name, adder)
			obj['Kart'] = file

			# Move the adder			
			obj.setParent(adder)
			obj.localPosition = [x*3, -y*3, 0]
			
			# Get the image and paste it into the final
			# texpath = gl.expandPath('//Karts/'+file+'/Icon.png')
			# if not os.path.exists(texpath):
				# texpath = gl.expandPath('//Karts/Icon.png')
				
			# img = Image.open(texpath)
			# final.paste(img, ((128*x), (128*y)))
			
			# Adjust the added object's uv coordinates
			mesh = obj.meshes[0]
			
			for v in range(0, 4):
				vert = mesh.getVertex(0, v)
				
			
			x += 1
			if x == 5:
				x = 0
				y += 1
				
			icon += 1
				
	#end for
	
	final.save(gl.expandPath('//tmp.png'))	
	
	# Create the imag
	# width = 128*5 if y > 0 else 128*x
	# height = 128*(y+1)
	
	# final = Image.new('RGB', (width, height))
	
	# x = 0
	# y = 0
	# for image in images:
		# posx = 128*x
		# posy = 128*y
		# final.paste(image, (posx, posy))
		
		# x += 1
		# if x == 5:
			# x = 0
			# y += 1
		
	
	# Change the texture
	# texpath = gl.expandPath('//tmp.png')

	# matid = vt.materialID(obj, 'MACharIcon')
	# obj['vt'] = vt.Texture(obj, matid)
	# image = gl.expandPath(texpath)
	
	# obj['vt'].source = vt.ImageFFmpeg(image)
	# obj['vt'].refresh(True)

def DisplayOptions():
	import Options, GameLogic as gl
	scene = gl.getCurrentScene()
	
	UseMouseTurn = scene.objects['OBUseMouseTurn.txt']
	
	UseMouseTurn['Text'] = "Yes" if Options.GetValue('UseMouseTurn') else "No"
				
def Main(cont):
	import Options
	own = cont.owner
	name = own.name[2:]
	
	# Init the mouse if it hasn't been
	import GameLogic
	if not hasattr(GameLogic, 'mouse'):
		import Rasterizer
		Rasterizer.showMouse(True)
		GameLogic.mouse = True
		
	# Load the options
	if 'Init' not in GameLogic.globalDict:
		Options.LoadOptions(cont)
		
	# The character select screen text
	CharText = GameLogic.getCurrentScene().objects['OBCharText']
	
	# Sensors
	mouseOver = cont.sensors['mouse_move']
	mouseClick = cont.sensors['mouse_click']
	
	# Actuators
	# quit = cont.actuators['quit']
	# start = cont.actuators['start']

	if mouseClick.positive and mouseOver.positive:
		btn = mouseOver.hitObject.name[2:]
		
		# Main menu
		if btn == "StartGame":
			own.sendMessage('main_off')
			own.sendMessage('char_on')
			#DisplayChars()
		elif btn == "Options":
			own.sendMessage('main_off')
			own.sendMessage('options_on')
			DisplayOptions()
		elif btn == "Quit":
			cont.activate('quit')
			
		# Character select
		elif btn[:4] == "Icon":
			CharText['Text'] = mouseOver.hitObject.name[7:]
		elif btn == "Select":
			if CharText['Text'] != "Choose a Kart!":
				Options.ChangeOption('Kart', CharText['Text'])
				Options.SaveOptions(cont)
				start = cont.actuators['start']
				cont.activate(start)			
		elif btn == "BackChar":
			own.sendMessage('char_off')
			own.sendMessage('main_on')
			
		# Options
		elif btn == "UseMouseTurn":
			Options.ToogleOption('UseMouseTurn')
			DisplayOptions()
		elif btn == "Defaults":
			Options.LoadDefaults()
			DisplayOptions()
			Options.SaveOptions(cont)
		elif btn == "BackOp":
			Options.SaveOptions(cont)
			own.sendMessage('options_off')
			own.sendMessage('main_on')